package com.letwal.cmcvnd.assetdetail

import android.annotation.SuppressLint
import android.view.View
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel
import com.loper7.tab_expand.ext.buildIndicator
import com.loper7.tab_expand.ext.buildText
import com.loper7.tab_expand.indicator.LinearIndicator
import com.loper7.tab_expand.text.BaseText
import com.letwal.cmcvnd.R
import com.letwal.cmcvnd.base.BaseActivity
import com.letwal.cmcvnd.assetdetail.adapter.AssetFragmentAdapter
import com.letwal.cmcvnd.enums.PageTagEnum
import com.letwal.cmcvnd.extend.*
import com.letwal.cmcvnd.databinding.ActivityAssetDetailBinding

/** asset详情页 */
@SuppressLint("CustomSplashScreen")
class AssetDetailActivity : BaseActivity() {

    //布局binding
    private lateinit var mActivityBinding: ActivityAssetDetailBinding

    //适配器
    private lateinit var mAssetFragmentAdapter: AssetFragmentAdapter

    override fun onBindingViewModel(): List<ViewModel> {
        val list = mutableListOf<ViewModel>()
        return list
    }

    override fun onBindingViewTag(): String {
        return PageTagEnum.my_wallet.name.uppercase()
    }

    override fun onBindingContentView(): View {
        mActivityBinding =
            ActivityAssetDetailBinding.inflate(layoutInflater)
        return mActivityBinding.root
    }

    override fun onContentViewBinded() {
        try {
            //初始化配置参数
            val name = intent.getStringExtra("name").toString()

            //初始化fragment列表
            mAssetFragmentAdapter = AssetFragmentAdapter(supportFragmentManager)
            mActivityBinding.viewPageAssetDetailTabLayout
                .adapter = mAssetFragmentAdapter
            mActivityBinding.tabLayoutAssetDetail
                .setupWithViewPager(mActivityBinding.viewPageAssetDetailTabLayout)

            //tablayout
            mActivityBinding.tabLayoutAssetDetail.buildIndicator<LinearIndicator>()
                .setColor(ContextCompat.getColor(this, R.color.main_blue))
                .bind()
            mActivityBinding.tabLayoutAssetDetail.buildText<BaseText>()
                .setNormalTextBold(false)
                .setSelectTextBold(true)
                .setNormalTextSize(12f)
                .setSelectTextSize(14f)
                .bind()

        } catch (e: Exception) {
            e.printStackTrace()
        }
    }


}